 /*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Metodos;

import Atributos.*;
import BD.CriaConexao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author André
 */
public class ObjetoMet {

    
    private Connection conexao;
    
    
    public ObjetoMet(){
        try {
            this.conexao= (Connection) CriaConexao.getConexao();
        } catch (SQLException ex) {
            Logger.getLogger(ObjetoMet.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }

    public List<Objeto> CriaListObj() throws SQLException {
        String sql = "select DISTINCT dias.id_dias,aulas.id_aula,serie.id_serie,serie.nome_serie,descricao.descricao_desc,professor.id_prof,professor.nome_prof,professor.carga_horaria,disciplina.id_disc,disciplina.nome_disc,disciplina.eixo,hora_aula.id_ha,hora_aula.horas_aula from serie,descricao,professor,disciplina,hora_aula,aulas,dias,prof_dia_aula where prof_dia_aula.id_prof_pda=professor.id_prof and prof_dia_aula.id_dia_pda=dias.id_dias and prof_dia_aula.id_aula_pda=aulas.id_aula and hora_aula.id_serie_turma_ha=serie.id_serie and serie.id_turma_s=descricao.id_desc and hora_aula.id_prof_ha=professor.id_prof and hora_aula.id_disc_ha=disciplina.id_disc order by disciplina.eixo ,serie.nome_serie, descricao.descricao_desc, dias.id_dias, aulas.id_aula ";
        List<Objeto> minhaLista;
        try (PreparedStatement stmt = (PreparedStatement) conexao.prepareStatement(sql); ResultSet rs = (ResultSet) stmt.executeQuery()) {
            minhaLista = new ArrayList<>();
            while (rs.next()) {
                Objeto a1 = new Objeto();
                a1.setDia(rs.getInt("id_dias"));
                a1.setAula(rs.getInt("id_aula"));
                a1.setId_serie(rs.getInt("id_serie"));
                a1.setAno(rs.getString("nome_serie"));
                a1.setTurma(rs.getString("descricao_desc"));
                a1.setAnoturma(rs.getString("nome_serie")+rs.getString("descricao_desc"));
                a1.setId_prof(rs.getInt("id_prof"));
                a1.setNomeprof(rs.getString("nome_prof")); 
                a1.setCH(rs.getInt("carga_horaria"));
                a1.setId_disc(rs.getInt("id_disc"));
                a1.setNomedisc(rs.getString("nome_disc"));
                a1.setEixo(rs.getString("eixo"));
                a1.setId_HA(rs.getInt("id_ha"));
                a1.setHA(rs.getInt("horas_aula"));     
            minhaLista.add(a1);
            }
        }
        return minhaLista;
    }
    
    public List<Objeto> CriaListObjV() throws SQLException {
        String sql = "select DISTINCT dias.id_dias,aulas.id_aula,serie.id_serie,serie.nome_serie,descricao.descricao_desc,professor.id_prof,professor.nome_prof,professor.carga_horaria,disciplina.id_disc,disciplina.nome_disc,disciplina.eixo,hora_aula.id_ha,hora_aula.horas_aula from serie,descricao,professor,disciplina,hora_aula,aulas,dias,prof_dia_aula where prof_dia_aula.id_prof_pda=professor.id_prof and prof_dia_aula.id_dia_pda=dias.id_dias and prof_dia_aula.id_aula_pda=aulas.id_aula and hora_aula.id_serie_turma_ha=serie.id_serie and serie.id_turma_s=descricao.id_desc and hora_aula.id_prof_ha=professor.id_prof and hora_aula.id_disc_ha=disciplina.id_disc order by disciplina.eixo ,serie.nome_serie, descricao.descricao_desc";
        List<Objeto> minhaLista;
        try (PreparedStatement stmt = (PreparedStatement) conexao.prepareStatement(sql); ResultSet rs = (ResultSet) stmt.executeQuery()) {
            minhaLista = new ArrayList<>();
            while (rs.next()) {
                Objeto a1 = new Objeto();
                a1.setDia(rs.getInt("id_dias"));
                a1.setAula(rs.getInt("id_aula"));
                a1.setId_serie(rs.getInt("id_serie"));
                a1.setAno(rs.getString("nome_serie"));
                a1.setTurma(rs.getString("descricao_desc"));
                a1.setAnoturma(rs.getString("nome_serie")+rs.getString("descricao_desc"));
                a1.setId_prof(rs.getInt("id_prof"));
                a1.setNomeprof(rs.getString("nome_prof")); 
                a1.setCH(rs.getInt("carga_horaria"));
                a1.setId_disc(rs.getInt("id_disc"));
                a1.setNomedisc(rs.getString("nome_disc"));
                a1.setEixo(rs.getString("eixo"));
                a1.setId_HA(rs.getInt("id_ha"));
                a1.setHA(rs.getInt("horas_aula"));     
            minhaLista.add(a1);
            }
        }
        return minhaLista;
    }
    
    public List<Objeto> CriaListObjPorProDisc(Professor prof, Disciplina disc) throws SQLException {
        String sql = "select DISTINCT dias.id_dias,aulas.id_aula,serie.id_serie,serie.nome_serie,descricao.descricao_desc,professor.id_prof,professor.nome_prof,professor.carga_horaria,disciplina.id_disc,disciplina.nome_disc,disciplina.eixo,hora_aula.id_ha,hora_aula.horas_aula from serie,descricao,professor,disciplina,hora_aula,aulas,dias,prof_dia_aula where prof_dia_aula.id_prof_pda=professor.id_prof and prof_dia_aula.id_dia_pda=dias.id_dias and prof_dia_aula.id_aula_pda=aulas.id_aula and hora_aula.id_serie_turma_ha=serie.id_serie and serie.id_turma_s=descricao.id_desc and hora_aula.id_prof_ha=professor.id_prof and hora_aula.id_disc_ha=disciplina.id_disc and professor.id_prof=? and disciplina.id_disc=? order by disciplina.eixo, serie.nome_serie, descricao.descricao_desc , dias.id_dias, aulas.id_aula ";
        List<Objeto> minhaLista;
      PreparedStatement stmt = (PreparedStatement) conexao.prepareStatement(sql); 
              stmt.setInt(1, prof.getId() );
              stmt.setInt(2, disc.getId_disc() );
                ResultSet rs = (ResultSet) stmt.executeQuery(); 
            minhaLista = new ArrayList<>();
            while (rs.next()) {
                Objeto a1 = new Objeto();
                a1.setDia(rs.getInt("id_dias"));
                a1.setAula(rs.getInt("id_aula"));
                a1.setId_serie(rs.getInt("id_serie"));
                a1.setAno(rs.getString("nome_serie"));
                a1.setTurma(rs.getString("descricao_desc"));
                a1.setAnoturma(rs.getString("nome_serie")+rs.getString("descricao_desc"));
                a1.setId_prof(rs.getInt("id_prof"));
                a1.setNomeprof(rs.getString("nome_prof")); 
                a1.setCH(rs.getInt("carga_horaria"));
                a1.setId_disc(rs.getInt("id_disc"));
                a1.setNomedisc(rs.getString("nome_disc"));
                a1.setEixo(rs.getString("eixo"));
                a1.setId_HA(rs.getInt("id_ha"));
                a1.setHA(rs.getInt("horas_aula"));     
            minhaLista.add(a1);
            }
        
        return minhaLista;
    }
    
    public List<Objeto> CriaListObj3aula() throws SQLException {
        String sql = "select DISTINCT dias.id_dias,aulas.id_aula,serie.id_serie,serie.nome_serie,descricao.descricao_desc,professor.id_prof,professor.nome_prof,professor.carga_horaria,disciplina.id_disc,disciplina.nome_disc,disciplina.eixo,hora_aula.id_ha,hora_aula.horas_aula from serie,descricao,professor,disciplina,hora_aula,aulas,dias,prof_dia_aula where prof_dia_aula.id_prof_pda=professor.id_prof and prof_dia_aula.id_dia_pda=dias.id_dias and prof_dia_aula.id_aula_pda=aulas.id_aula and hora_aula.id_serie_turma_ha=serie.id_serie and serie.id_turma_s=descricao.id_desc and hora_aula.id_prof_ha=professor.id_prof and hora_aula.id_disc_ha=disciplina.id_disc and hora_aula.horas_aula>=3 and disciplina.eixo='Profissional' order by disciplina.eixo, serie.nome_serie, descricao.descricao_desc , dias.id_dias, aulas.id_aula ";
        List<Objeto> minhaLista;
        try (PreparedStatement stmt = (PreparedStatement) conexao.prepareStatement(sql); ResultSet rs = (ResultSet) stmt.executeQuery()) {
            minhaLista = new ArrayList<>();
            while (rs.next()) {
                Objeto a1 = new Objeto();
                a1.setDia(rs.getInt("id_dias"));
                a1.setAula(rs.getInt("id_aula"));
                a1.setId_serie(rs.getInt("id_serie"));
                a1.setAno(rs.getString("nome_serie"));
                a1.setTurma(rs.getString("descricao_desc"));
                a1.setAnoturma(rs.getString("nome_serie")+rs.getString("descricao_desc"));
                a1.setId_prof(rs.getInt("id_prof"));
                a1.setNomeprof(rs.getString("nome_prof")); 
                a1.setCH(rs.getInt("carga_horaria"));
                a1.setId_disc(rs.getInt("id_disc"));
                a1.setNomedisc(rs.getString("nome_disc"));
                a1.setEixo(rs.getString("eixo"));
                a1.setId_HA(rs.getInt("id_ha"));
                a1.setHA(rs.getInt("horas_aula"));     
            minhaLista.add(a1);
            }
        }
        return minhaLista;
    }
    
    public List<Objeto> CriaListObj2aulas() throws SQLException {
        String sql = "select DISTINCT dias.id_dias,aulas.id_aula,serie.id_serie,serie.nome_serie,descricao.descricao_desc,professor.id_prof,professor.nome_prof,professor.carga_horaria,disciplina.id_disc,disciplina.nome_disc,disciplina.eixo,hora_aula.id_ha,hora_aula.horas_aula from serie,descricao,professor,disciplina,hora_aula,aulas,dias,prof_dia_aula where prof_dia_aula.id_prof_pda=professor.id_prof and prof_dia_aula.id_dia_pda=dias.id_dias and prof_dia_aula.id_aula_pda=aulas.id_aula and hora_aula.id_serie_turma_ha=serie.id_serie and serie.id_turma_s=descricao.id_desc and hora_aula.id_prof_ha=professor.id_prof and hora_aula.id_disc_ha=disciplina.id_disc and hora_aula.horas_aula>=2 order by disciplina.eixo, serie.nome_serie, descricao.descricao_desc , dias.id_dias, aulas.id_aula ";
        List<Objeto> minhaLista;
        try (PreparedStatement stmt = (PreparedStatement) conexao.prepareStatement(sql); ResultSet rs = (ResultSet) stmt.executeQuery()) {
            minhaLista = new ArrayList<>();
            while (rs.next()) {
                Objeto a1 = new Objeto();
                a1.setDia(rs.getInt("id_dias"));
                a1.setAula(rs.getInt("id_aula"));
                a1.setId_serie(rs.getInt("id_serie"));
                a1.setAno(rs.getString("nome_serie"));
                a1.setTurma(rs.getString("descricao_desc"));
                a1.setAnoturma(rs.getString("nome_serie")+rs.getString("descricao_desc"));
                a1.setId_prof(rs.getInt("id_prof"));
                a1.setNomeprof(rs.getString("nome_prof")); 
                a1.setCH(rs.getInt("carga_horaria"));
                a1.setId_disc(rs.getInt("id_disc"));
                a1.setNomedisc(rs.getString("nome_disc"));
                a1.setEixo(rs.getString("eixo"));
                a1.setId_HA(rs.getInt("id_ha"));
                a1.setHA(rs.getInt("horas_aula"));     
            minhaLista.add(a1);
            }
        }
        return minhaLista;
    }
    
    public List<Objeto> CriaListObj1aula() throws SQLException {
        String sql = "select DISTINCT dias.id_dias,aulas.id_aula,serie.id_serie,serie.nome_serie,descricao.descricao_desc,professor.id_prof,professor.nome_prof,professor.carga_horaria,disciplina.id_disc,disciplina.nome_disc,disciplina.eixo,hora_aula.id_ha,hora_aula.horas_aula from serie,descricao,professor,disciplina,hora_aula,aulas,dias,prof_dia_aula where prof_dia_aula.id_prof_pda=professor.id_prof and prof_dia_aula.id_dia_pda=dias.id_dias and prof_dia_aula.id_aula_pda=aulas.id_aula and hora_aula.id_serie_turma_ha=serie.id_serie and serie.id_turma_s=descricao.id_desc and hora_aula.id_prof_ha=professor.id_prof and hora_aula.id_disc_ha=disciplina.id_disc and hora_aula.horas_aula=1 order by disciplina.eixo, serie.nome_serie, descricao.descricao_desc  , dias.id_dias, aulas.id_aula";
        List<Objeto> minhaLista;
        try (PreparedStatement stmt = (PreparedStatement) conexao.prepareStatement(sql); ResultSet rs = (ResultSet) stmt.executeQuery()) {
            minhaLista = new ArrayList<>();
            while (rs.next()) {
                Objeto a1 = new Objeto();
                a1.setDia(rs.getInt("id_dias"));
                a1.setAula(rs.getInt("id_aula"));
                a1.setId_serie(rs.getInt("id_serie"));
                a1.setAno(rs.getString("nome_serie"));
                a1.setTurma(rs.getString("descricao_desc"));
                a1.setAnoturma(rs.getString("nome_serie")+rs.getString("descricao_desc"));
                a1.setId_prof(rs.getInt("id_prof"));
                a1.setNomeprof(rs.getString("nome_prof")); 
                a1.setCH(rs.getInt("carga_horaria"));
                a1.setId_disc(rs.getInt("id_disc"));
                a1.setNomedisc(rs.getString("nome_disc"));
                a1.setEixo(rs.getString("eixo"));
                a1.setId_HA(rs.getInt("id_ha"));
                a1.setHA(rs.getInt("horas_aula"));     
            minhaLista.add(a1);
            }
        }
        return minhaLista;
    }
    
    public List<Objeto> CriaListObjPara3ano() throws SQLException {
        String sql = "select dias.id_dias,aulas.id_aula,serie.id_serie,serie.nome_serie,descricao.descricao_desc,professor.id_prof,professor.nome_prof,professor.carga_horaria,disciplina.id_disc,disciplina.nome_disc,disciplina.eixo,hora_aula.id_ha,hora_aula.horas_aula from serie,descricao,professor,disciplina,hora_aula,aulas,dias,prof_dia_aula where prof_dia_aula.id_prof_pda=professor.id_prof and prof_dia_aula.id_dia_pda=dias.id_dias and prof_dia_aula.id_aula_pda=aulas.id_aula and hora_aula.id_serie_turma_ha=serie.id_serie and serie.id_turma_s=descricao.id_desc and hora_aula.id_prof_ha=professor.id_prof and hora_aula.id_disc_ha=disciplina.id_disc and serie.nome_serie='3' order by disciplina.eixo DESC, serie.nome_serie, descricao.descricao_desc, dias.id_dias, aulas.id_aula";
        List<Objeto> minhaLista;
        try (PreparedStatement stmt = (PreparedStatement) conexao.prepareStatement(sql); ResultSet rs = (ResultSet) stmt.executeQuery()) {
            minhaLista = new ArrayList<>();
            while (rs.next()) {
                Objeto a1 = new Objeto();
                a1.setDia(rs.getInt("id_dias"));
                a1.setAula(rs.getInt("id_aula"));
                a1.setId_serie(rs.getInt("id_serie"));
                a1.setAno(rs.getString("nome_serie"));
                a1.setTurma(rs.getString("descricao_desc"));
                a1.setAnoturma(rs.getString("nome_serie")+rs.getString("descricao_desc"));
                a1.setId_prof(rs.getInt("id_prof"));
                a1.setNomeprof(rs.getString("nome_prof")); 
                a1.setCH(rs.getInt("carga_horaria"));
                a1.setId_disc(rs.getInt("id_disc"));
                a1.setNomedisc(rs.getString("nome_disc"));
                a1.setEixo(rs.getString("eixo"));
                a1.setId_HA(rs.getInt("id_ha"));
                a1.setHA(rs.getInt("horas_aula"));     
            minhaLista.add(a1);
            }
        }
        return minhaLista;
    }
     
    public List<Objeto> CriaListObjPara3ano10aula() throws SQLException {
        String sql = "select dias.id_dias,aulas.id_aula,serie.id_serie,serie.nome_serie,descricao.descricao_desc,professor.id_prof,professor.nome_prof,professor.carga_horaria,disciplina.id_disc,disciplina.nome_disc,disciplina.eixo,hora_aula.id_ha,hora_aula.horas_aula from serie,descricao,professor,disciplina,hora_aula,aulas,dias,prof_dia_aula where prof_dia_aula.id_prof_pda=professor.id_prof and prof_dia_aula.id_dia_pda=dias.id_dias and prof_dia_aula.id_aula_pda=aulas.id_aula and hora_aula.id_serie_turma_ha=serie.id_serie and serie.id_turma_s=descricao.id_desc and hora_aula.id_prof_ha=professor.id_prof and hora_aula.id_disc_ha=disciplina.id_disc and serie.nome_serie='3' and aulas.id_aula=10 order by disciplina.eixo DESC, serie.nome_serie, descricao.descricao_desc, dias.id_dias, aulas.id_aula";
        List<Objeto> minhaLista;
        try (PreparedStatement stmt = (PreparedStatement) conexao.prepareStatement(sql); ResultSet rs = (ResultSet) stmt.executeQuery()) {
            minhaLista = new ArrayList<>();
            while (rs.next()) {
                Objeto a1 = new Objeto();
                a1.setDia(rs.getInt("id_dias"));
                a1.setAula(rs.getInt("id_aula"));
                a1.setId_serie(rs.getInt("id_serie"));
                a1.setAno(rs.getString("nome_serie"));
                a1.setTurma(rs.getString("descricao_desc"));
                a1.setAnoturma(rs.getString("nome_serie")+rs.getString("descricao_desc"));
                a1.setId_prof(rs.getInt("id_prof"));
                a1.setNomeprof(rs.getString("nome_prof")); 
                a1.setCH(rs.getInt("carga_horaria"));
                a1.setId_disc(rs.getInt("id_disc"));
                a1.setNomedisc(rs.getString("nome_disc"));
                a1.setEixo(rs.getString("eixo"));
                a1.setId_HA(rs.getInt("id_ha"));
                a1.setHA(rs.getInt("horas_aula"));     
            minhaLista.add(a1);
            }
        }
        return minhaLista;
    }
     
    public List<Objeto> CriaListObjPara3anode2aulas() throws SQLException {
        String sql = "select dias.id_dias,aulas.id_aula,serie.id_serie,serie.nome_serie,descricao.descricao_desc,professor.id_prof,professor.nome_prof,professor.carga_horaria,disciplina.id_disc,disciplina.nome_disc,disciplina.eixo,hora_aula.id_ha,hora_aula.horas_aula from serie,descricao,professor,disciplina,hora_aula,aulas,dias,prof_dia_aula where prof_dia_aula.id_prof_pda=professor.id_prof and prof_dia_aula.id_dia_pda=dias.id_dias and prof_dia_aula.id_aula_pda=aulas.id_aula and hora_aula.id_serie_turma_ha=serie.id_serie and serie.id_turma_s=descricao.id_desc and hora_aula.id_prof_ha=professor.id_prof and hora_aula.id_disc_ha=disciplina.id_disc and serie.nome_serie='3' and hora_aula.horas_aula>=2 order by disciplina.eixo DESC, serie.nome_serie, descricao.descricao_desc, dias.id_dias, aulas.id_aula";
            List<Objeto> minhaLista;
        try (PreparedStatement stmt = (PreparedStatement) conexao.prepareStatement(sql); ResultSet rs = (ResultSet) stmt.executeQuery()) {
            minhaLista = new ArrayList<>();
            while (rs.next()) {
                Objeto a1 = new Objeto();
                a1.setDia(rs.getInt("id_dias"));
                a1.setAula(rs.getInt("id_aula"));
                a1.setId_serie(rs.getInt("id_serie"));
                a1.setAno(rs.getString("nome_serie"));
                a1.setTurma(rs.getString("descricao_desc"));
                a1.setAnoturma(rs.getString("nome_serie")+rs.getString("descricao_desc"));
                a1.setId_prof(rs.getInt("id_prof"));
                a1.setNomeprof(rs.getString("nome_prof")); 
                a1.setCH(rs.getInt("carga_horaria"));
                a1.setId_disc(rs.getInt("id_disc"));
                a1.setNomedisc(rs.getString("nome_disc"));
                a1.setEixo(rs.getString("eixo"));
                a1.setId_HA(rs.getInt("id_ha"));
                a1.setHA(rs.getInt("horas_aula"));     
            minhaLista.add(a1);
            }
        }
        return minhaLista;
    }
      
    public List<Objeto> CriaListObjPara3anode1aula() throws SQLException {
        String sql = "select dias.id_dias,aulas.id_aula,serie.id_serie,serie.nome_serie,descricao.descricao_desc,professor.id_prof,professor.nome_prof,professor.carga_horaria,disciplina.id_disc,disciplina.nome_disc,disciplina.eixo,hora_aula.id_ha,hora_aula.horas_aula from serie,descricao,professor,disciplina,hora_aula,aulas,dias,prof_dia_aula where prof_dia_aula.id_prof_pda=professor.id_prof and prof_dia_aula.id_dia_pda=dias.id_dias and prof_dia_aula.id_aula_pda=aulas.id_aula and hora_aula.id_serie_turma_ha=serie.id_serie and serie.id_turma_s=descricao.id_desc and hora_aula.id_prof_ha=professor.id_prof and hora_aula.id_disc_ha=disciplina.id_disc and serie.nome_serie='3' and hora_aula.horas_aula=1 order by disciplina.eixo DESC, serie.nome_serie, descricao.descricao_desc, dias.id_dias, aulas.id_aula";
            List<Objeto> minhaLista;
        try (PreparedStatement stmt = (PreparedStatement) conexao.prepareStatement(sql); ResultSet rs = (ResultSet) stmt.executeQuery()) {
            minhaLista = new ArrayList<>();
            while (rs.next()) {
                Objeto a1 = new Objeto();
                a1.setDia(rs.getInt("id_dias"));
                a1.setAula(rs.getInt("id_aula"));
                a1.setId_serie(rs.getInt("id_serie"));
                a1.setAno(rs.getString("nome_serie"));
                a1.setTurma(rs.getString("descricao_desc"));
                a1.setAnoturma(rs.getString("nome_serie")+rs.getString("descricao_desc"));
                a1.setId_prof(rs.getInt("id_prof"));
                a1.setNomeprof(rs.getString("nome_prof")); 
                a1.setCH(rs.getInt("carga_horaria"));
                a1.setId_disc(rs.getInt("id_disc"));
                a1.setNomedisc(rs.getString("nome_disc"));
                a1.setEixo(rs.getString("eixo"));
                a1.setId_HA(rs.getInt("id_ha"));
                a1.setHA(rs.getInt("horas_aula"));     
            minhaLista.add(a1);
            }
        }
        return minhaLista;
    }

    public void Remove1daCHeHA (int id_prof,int CH,int HA,int id_HA) {
         String sql = " update professor set carga_horaria=? where id_prof=?";
        PreparedStatement stmt;
        try {
            stmt = (PreparedStatement) conexao.prepareStatement(sql);
             stmt.setInt(1, CH-1);
             stmt.setInt(2, id_prof);
            stmt.execute();
            stmt.close();
        } catch (SQLException ex) {
            Logger.getLogger(ObjetoMet.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        String sql2 = " update hora_aula set horas_aula=? where id_ha=?";
        PreparedStatement stmt2;
        try {
            stmt2 = (PreparedStatement) conexao.prepareStatement(sql2);
             stmt2.setInt(1, HA-1);
             stmt2.setInt(2, id_HA);
            stmt2.execute();
            stmt2.close();
        } catch (SQLException ex) {
            Logger.getLogger(ObjetoMet.class.getName()).log(Level.SEVERE, null, ex);
        }
         String sql3 = "select horas_aula from hora_aula where id_ha=?";
            PreparedStatement stmt3;
        try {
            stmt3 = (PreparedStatement) conexao.prepareStatement(sql3);
            stmt3.setInt(1, id_HA);
           
            ResultSet rs3 = stmt3.executeQuery();
            
            while (rs3.next()){
               HorasAula ha=new HorasAula();
               
               ha.setHoras_aula(rs3.getInt("horas_aula"));
               if(ha.getHoras_aula()==0){
                   DadosStatic.setDadosinsersos(DadosStatic.getDadosinsersos()+1);
                                    String sql_4 = "delete from hora_aula where id_ha = ?";
                                    PreparedStatement consulta_4;
                                    try {
                                    consulta_4 = (PreparedStatement) conexao.prepareStatement(sql_4);
                                    consulta_4.setInt(1, id_HA);
                                    consulta_4.execute();
                                    consulta_4.close();
                                    } catch (SQLException ex) {
                                        Logger.getLogger(ObjetoMet.class.getName()).log(Level.SEVERE, null, ex);
                                    }
            
               } 
                
                
            }
            rs3.close();
            stmt3.close();
            
             
            
            
            
            
            
        } catch (SQLException ex) {
            Logger.getLogger(ObjetoMet.class.getName()).log(Level.SEVERE, null, ex);
        }
       System.out.println("DELETOU A: "+id_HA+" DO PROF: "+id_prof+" Remove 1 aula HA");
    }

    public List<Objeto> CriaListObj2(Objeto obj,int y) throws SQLException {
        
       String sql = "select dias.id_dias,aulas.id_aula,serie.id_serie,serie.nome_serie,descricao.descricao_desc,professor.id_prof,professor.nome_prof,professor.carga_horaria,disciplina.id_disc,disciplina.nome_disc,disciplina.eixo,hora_aula.id_ha,hora_aula.horas_aula from serie,descricao,professor,disciplina,hora_aula,aulas,dias,prof_dia_aula where prof_dia_aula.id_prof_pda=professor.id_prof and prof_dia_aula.id_dia_pda=dias.id_dias and prof_dia_aula.id_aula_pda=aulas.id_aula and hora_aula.id_serie_turma_ha=serie.id_serie and serie.id_turma_s=descricao.id_desc and hora_aula.id_prof_ha=professor.id_prof and hora_aula.id_disc_ha=disciplina.id_disc and prof_dia_aula.id_prof_pda=? and aulas.id_aula=? and dias.id_dias=? and disciplina.id_disc=? and serie.id_serie=? and descricao.descricao_desc=?";
        List<Objeto> minhaLista;
        try (PreparedStatement stmt = (PreparedStatement) conexao.prepareStatement(sql)) {
            stmt.setInt(1, obj.getId_prof());
            stmt.setInt(2, y+1);
            stmt.setInt(3, obj.getDia());
            stmt.setInt(4, obj.getId_disc());
            stmt.setInt(5, obj.getId_serie());
            stmt.setString(6, obj.getTurma());
            try (ResultSet rs = (ResultSet) stmt.executeQuery()) {
                minhaLista = new ArrayList<>();
                while (rs.next()) {
                    Objeto a1 = new Objeto();
                    a1.setDia(rs.getInt("id_dias"));
                    a1.setAula(rs.getInt("id_aula"));
                    a1.setId_serie(rs.getInt("id_serie"));
                    a1.setAno(rs.getString("nome_serie"));
                    a1.setTurma(rs.getString("descricao_desc"));
                    a1.setAnoturma(rs.getString("nome_serie")+rs.getString("descricao_desc"));
                    a1.setId_prof(rs.getInt("id_prof"));
                    a1.setNomeprof(rs.getString("nome_prof")); 
                    a1.setCH(rs.getInt("carga_horaria"));
                    a1.setId_disc(rs.getInt("id_disc"));
                    a1.setNomedisc(rs.getString("nome_disc"));
                    a1.setEixo(rs.getString("eixo"));
                    a1.setId_HA(rs.getInt("id_ha"));
                    a1.setHA(rs.getInt("horas_aula"));
                minhaLista.add(a1);
                }
            }
        }
        return minhaLista;
    }

    public void Remove2daCHeHA(int id_prof, int CH, int HA, int id_HA) {
       String sql = " update professor set carga_horaria=? where id_prof=?";
        PreparedStatement stmt;
        try {
            stmt = (PreparedStatement) conexao.prepareStatement(sql);
             stmt.setInt(1, CH-2);
             stmt.setInt(2, id_prof);
            stmt.execute();
            stmt.close();
        } catch (SQLException ex) {
            Logger.getLogger(ObjetoMet.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        String sql2 = " update hora_aula set horas_aula=? where id_ha=?";
        PreparedStatement stmt2;
        try {
            stmt2 = (PreparedStatement) conexao.prepareStatement(sql2);
             stmt2.setInt(1, HA-2);
             stmt2.setInt(2, id_HA);
            stmt2.execute();
            stmt2.close();
        } catch (SQLException ex) {
            Logger.getLogger(ObjetoMet.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        
        String sql3 = "select horas_aula from hora_aula where id_ha=?";
            PreparedStatement stmt3;
        try {
            stmt3 = (PreparedStatement) conexao.prepareStatement(sql3);
            stmt3.setInt(1, id_HA);
           
            ResultSet rs3 = stmt3.executeQuery();
            
            while (rs3.next()){
               HorasAula ha=new HorasAula();
               
               ha.setHoras_aula(rs3.getInt("horas_aula"));
               if(ha.getHoras_aula()==0){
                   
                                    String sql_4 = "delete from hora_aula where id_ha = ?";
                                    PreparedStatement consulta_4;
                                    try {
                                    consulta_4 = (PreparedStatement) conexao.prepareStatement(sql_4);
                                    consulta_4.setInt(1, id_HA);
                                    consulta_4.execute();
                                    consulta_4.close();
                                    } catch (SQLException ex) {
                                        Logger.getLogger(ObjetoMet.class.getName()).log(Level.SEVERE, null, ex);
                                    }
            
               } 
                
                
            }
            rs3.close();
            stmt3.close();
            
        } catch (SQLException ex) {
            Logger.getLogger(ObjetoMet.class.getName()).log(Level.SEVERE, null, ex);
        }
            
      
       
    }

    public void Remove3daCHeHA(int id_prof, int CH, int HA, int id_HA) {
       String sql = " update professor set carga_horaria=? where id_prof=?";
        PreparedStatement stmt;
        try {
            stmt = (PreparedStatement) conexao.prepareStatement(sql);
             stmt.setInt(1, CH-3);
             stmt.setInt(2, id_prof);
            stmt.execute();
            stmt.close();
        } catch (SQLException ex) {
            Logger.getLogger(ObjetoMet.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        String sql2 = " update hora_aula set horas_aula=? where id_ha=?";
        PreparedStatement stmt2;
        try {
            stmt2 = (PreparedStatement) conexao.prepareStatement(sql2);
             stmt2.setInt(1, HA-3);
             stmt2.setInt(2, id_HA);
            stmt2.execute();
            stmt2.close();
        } catch (SQLException ex) {
            Logger.getLogger(ObjetoMet.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        
        String sql3 = "select horas_aula from hora_aula where id_ha=?";
            PreparedStatement stmt3;
        try {
            stmt3 = (PreparedStatement) conexao.prepareStatement(sql3);
            stmt3.setInt(1, id_HA);
           
            ResultSet rs3 = stmt3.executeQuery();
            
            while (rs3.next()){
               HorasAula ha=new HorasAula();
               
               ha.setHoras_aula(rs3.getInt("horas_aula"));
               if(ha.getHoras_aula()==0){
                   DadosStatic.setDadosinsersos(DadosStatic.getDadosinsersos()+1);
                                    String sql_4 = "delete from hora_aula where id_ha = ?";
                                    PreparedStatement consulta_4;
                                    try {
                                    consulta_4 = (PreparedStatement) conexao.prepareStatement(sql_4);
                                    consulta_4.setInt(1, id_HA);
                                    consulta_4.execute();
                                    consulta_4.close();
                                    } catch (SQLException ex) {
                                        Logger.getLogger(ObjetoMet.class.getName()).log(Level.SEVERE, null, ex);
                                    }
            
               } 
                
                
            }
            rs3.close();
            stmt3.close();
            
        } catch (SQLException ex) {
            Logger.getLogger(ObjetoMet.class.getName()).log(Level.SEVERE, null, ex);
        }
            
      
       
    }
    
    public void Remove2diasaulasdisponivel(Objeto obj, Objeto obj2) {
        DadosStatic.setDadosinsersos(DadosStatic.getDadosinsersos()+2);
        String sql_e = "delete from prof_dia_aula where id_prof_pda= ? and id_dia_pda=? and id_aula_pda=? ";
        PreparedStatement consulta_e;
        try {
            consulta_e = (PreparedStatement) conexao.prepareStatement(sql_e);
             consulta_e.setInt(1, obj.getId_prof());
             consulta_e.setInt(2, obj.getDia());
              consulta_e.setInt(3, obj.getAula());
             
        consulta_e.execute();
        consulta_e.close();
        } catch (SQLException ex) {
            Logger.getLogger(ObjetoMet.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        
        String sql_1 = "delete from prof_dia_aula where id_prof_pda= ? and id_dia_pda=? and id_aula_pda=? ";
        PreparedStatement consulta_1;
        try {
            consulta_1 = (PreparedStatement) conexao.prepareStatement(sql_1);
             consulta_1.setInt(1, obj2.getId_prof());
             consulta_1.setInt(2, obj2.getDia());
             consulta_1.setInt(3, obj2.getAula());
             
        consulta_1.execute();
        consulta_1.close();
        } catch (SQLException ex) {
            Logger.getLogger(ObjetoMet.class.getName()).log(Level.SEVERE, null, ex);
        }
        System.out.println("DELETOU A: "+obj.getAula()+" DO PROF: "+obj.getNomeprof()+" Remove 2 aulas");
        System.out.println("DELETOU A: "+obj2.getAula()+" DO PROF: "+obj2.getNomeprof()+" Remove 2 aulas");
       
       
    }

    public void Remove1diasaulasdisponivel(Objeto obj) {
        DadosStatic.setDadosinsersos(DadosStatic.getDadosinsersos()+1);
       String sql_e = "delete from prof_dia_aula where id_prof_pda= ? and id_dia_pda=? and id_aula_pda=?";
        PreparedStatement consulta_e;
        try {
            consulta_e = (PreparedStatement) conexao.prepareStatement(sql_e);
             consulta_e.setInt(1, obj.getId_prof());
             consulta_e.setInt(2, obj.getDia());
              consulta_e.setInt(3, obj.getAula());
        consulta_e.execute();
        consulta_e.close();
        } catch (SQLException ex) {
            Logger.getLogger(ObjetoMet.class.getName()).log(Level.SEVERE, null, ex);
        }
        System.out.println("DELETOU A: "+obj.getAula()+"  DIA: "+obj.getDia()+" DO PROF: "+obj.getNomeprof()+" Remove 1 aula Dias Disponiveis"+" NA TURMA:"+obj.getAnoturma());
    }

    public void AdicionaRelatorio (List<EnviarAoBD> minhaLista) throws SQLException  {
        String sql_1 = "insert into relatorio (aulas,coluna1) values (?,?)";
        String sql_2 = "insert into relatorio (aulas,coluna1,coluna2) values (?,?,?)";
        String sql_3 = "insert into relatorio (aulas,coluna1,coluna2,coluna3) values (?,?,?,?)";
        String sql_4 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4) values (?,?,?,?,?)";
        String sql_5 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5) values (?,?,?,?,?,?)";
        String sql_6 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6) values (?,?,?,?,?,?,?)";
        String sql_7 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7) values (?,?,?,?,?,?,?,?)";
        String sql_8 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8) values (?,?,?,?,?,?,?,?,?)";
        String sql_9 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8,coluna9) values (?,?,?,?,?,?,?,?,?,?)";
        String sql_10 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8,coluna9,coluna10) values (?,?,?,?,?,?,?,?,?,?,?)";
        String sql_11 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8,coluna9,coluna10,coluna11) values (?,?,?,?,?,?,?,?,?,?,?,?)";
        String sql_12 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8,coluna9,coluna10,coluna11,coluna12) values (?,?,?,?,?,?,?,?,?,?,?,?,?)";
        String sql_13 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8,coluna9,coluna10,coluna11,coluna12,coluna13) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        String sql_14 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8,coluna9,coluna10,coluna11,coluna12,coluna13,coluna14) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        String sql_15 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8,coluna9,coluna10,coluna11,coluna12,coluna13,coluna14,coluna15) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        String sql_16 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8,coluna9,coluna10,coluna11,coluna12,coluna13,coluna14,coluna15,coluna16) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        String sql_17 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8,coluna9,coluna10,coluna11,coluna12,coluna13,coluna14,coluna15,coluna16,coluna17) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        String sql_18 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8,coluna9,coluna10,coluna11,coluna12,coluna13,coluna14,coluna15,coluna16,coluna17,coluna18) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        String sql_19 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8,coluna9,coluna10,coluna11,coluna12,coluna13,coluna14,coluna15,coluna16,coluna17,coluna18,coluna19) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        String sql_20 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8,coluna9,coluna10,coluna11,coluna12,coluna13,coluna14,coluna15,coluna16,coluna17,coluna18,coluna19,coluna20) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        String sql_21 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8,coluna9,coluna10,coluna11,coluna12,coluna13,coluna14,coluna15,coluna16,coluna17,coluna18,coluna19,coluna20,coluna21) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        String sql_22 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8,coluna9,coluna10,coluna11,coluna12,coluna13,coluna14,coluna15,coluna16,coluna17,coluna18,coluna19,coluna20,coluna21,coluna22) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        String sql_23 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8,coluna9,coluna10,coluna11,coluna12,coluna13,coluna14,coluna15,coluna16,coluna17,coluna18,coluna19,coluna20,coluna21,coluna22,coluna23) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        String sql_24 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8,coluna9,coluna10,coluna11,coluna12,coluna13,coluna14,coluna15,coluna16,coluna17,coluna18,coluna19,coluna20,coluna21,coluna22,coluna23,coluna24) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        
        
        
        int turmas=minhaLista.size()-1;
        System.out.println("lista: "+minhaLista.size()+"turmas: "+turmas);
        if(turmas==1){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_1)) {
                for(int i=1,ind=2;minhaLista.size()>i;i++,ind++){
                stmt.setString(1, minhaLista.get(0).getId_aula());
                stmt.setString(ind, minhaLista.get(i).getAula1());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==2){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_2)) {
                for(int i=1,ind=2;minhaLista.size()>i;i++,ind++){
                stmt.setString(1, minhaLista.get(0).getId_aula());
                stmt.setString(ind, minhaLista.get(i).getAula1());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==3){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_3)) {
                for(int i=1,ind=2;minhaLista.size()>i;i++,ind++){
                stmt.setString(1, minhaLista.get(0).getId_aula());
                stmt.setString(ind, minhaLista.get(i).getAula1());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==4){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_4)) {
                for(int i=1,ind=2;minhaLista.size()>i;i++,ind++){
                stmt.setString(1, minhaLista.get(0).getId_aula());
                stmt.setString(ind, minhaLista.get(i).getAula1());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==5){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_5)) {
                for(int i=1,ind=2;minhaLista.size()>i;i++,ind++){
                stmt.setString(1, minhaLista.get(0).getId_aula());
                stmt.setString(ind, minhaLista.get(i).getAula1());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==6){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_6)) {
                for(int i=1,ind=2;minhaLista.size()>i;i++,ind++){
                stmt.setString(1, minhaLista.get(0).getId_aula());
                stmt.setString(ind, minhaLista.get(i).getAula1());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==7){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_7)) {
                for(int i=1,ind=2;minhaLista.size()>i;i++,ind++){
                stmt.setString(1, minhaLista.get(0).getId_aula());
                stmt.setString(ind, minhaLista.get(i).getAula1());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==8){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_8)) {
                for(int i=1,ind=2;minhaLista.size()>i;i++,ind++){
                stmt.setString(1, minhaLista.get(0).getId_aula());
                stmt.setString(ind, minhaLista.get(i).getAula1());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==9){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_9)) {
                for(int i=1,ind=2;minhaLista.size()>i;i++,ind++){
                stmt.setString(1, minhaLista.get(0).getId_aula());
                stmt.setString(ind, minhaLista.get(i).getAula1());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==10){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_10)) {
                for(int i=1,ind=2;minhaLista.size()>i;i++,ind++){
                stmt.setString(1, minhaLista.get(0).getId_aula());
                stmt.setString(ind, minhaLista.get(i).getAula1());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==11){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_11)) {
                
                for(int i=1,ind=2;minhaLista.size()>i;i++,ind++){
                    
                stmt.setString(1, minhaLista.get(0).getId_aula());
                
                stmt.setString(ind, minhaLista.get(i).getAula1());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==12){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_12)) {
                for(int i=1,ind=2;minhaLista.size()>i;i++,ind++){
                stmt.setString(1, minhaLista.get(0).getId_aula());
                stmt.setString(ind, minhaLista.get(i).getAula1());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==13){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_13)) {
                for(int i=1,ind=2;minhaLista.size()>i;i++,ind++){
                stmt.setString(1, minhaLista.get(0).getId_aula());
                stmt.setString(ind, minhaLista.get(i).getAula1());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==14){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_14)) {
                for(int i=1,ind=2;minhaLista.size()>i;i++,ind++){
                stmt.setString(1, minhaLista.get(0).getId_aula());
                stmt.setString(ind, minhaLista.get(i).getAula1());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==15){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_15)) {
                for(int i=1,ind=2;minhaLista.size()>i;i++,ind++){
                stmt.setString(1, minhaLista.get(0).getId_aula());
                stmt.setString(ind, minhaLista.get(i).getAula1());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==16){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_16)) {
                for(int i=1,ind=2;minhaLista.size()>i;i++,ind++){
                stmt.setString(1, minhaLista.get(0).getId_aula());
                stmt.setString(ind, minhaLista.get(i).getAula1());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==17){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_17)) {
                for(int i=1,ind=2;minhaLista.size()>i;i++,ind++){
                stmt.setString(1, minhaLista.get(0).getId_aula());
                stmt.setString(ind, minhaLista.get(i).getAula1());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==18){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_18)) {
                for(int i=1,ind=2;minhaLista.size()>i;i++,ind++){
                stmt.setString(1, minhaLista.get(0).getId_aula());
                stmt.setString(ind, minhaLista.get(i).getAula1());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==19){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_19)) {
                for(int i=1,ind=2;minhaLista.size()>i;i++,ind++){
                stmt.setString(1, minhaLista.get(0).getId_aula());
                stmt.setString(ind, minhaLista.get(i).getAula1());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==20){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_20)) {
                for(int i=1,ind=2;minhaLista.size()>i;i++,ind++){
                stmt.setString(1, minhaLista.get(0).getId_aula());
                stmt.setString(ind, minhaLista.get(i).getAula1());
                                                                 }
                stmt.execute();
            }
                     }
        
        if(turmas==21){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_21)) {
                for(int i=1,ind=2;minhaLista.size()>i;i++,ind++){
                stmt.setString(1, minhaLista.get(0).getId_aula());
                stmt.setString(ind, minhaLista.get(i).getAula1());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==22){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_22)) {
                for(int i=1,ind=2;minhaLista.size()>i;i++,ind++){
                stmt.setString(1, minhaLista.get(0).getId_aula());
                stmt.setString(ind, minhaLista.get(i).getAula1());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==23){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_23)) {
                for(int i=1,ind=2;minhaLista.size()>i;i++,ind++){
                stmt.setString(1, minhaLista.get(0).getId_aula());
                stmt.setString(ind, minhaLista.get(i).getAula1());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==24){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_24)) {
                for(int i=1,ind=2;minhaLista.size()>i;i++,ind++){
                stmt.setString(1, minhaLista.get(0).getId_aula());
                stmt.setString(ind, minhaLista.get(i).getAula1());
                                                                 }
                stmt.execute();
            }
                     }
        
    }
    
    public void AdicionaRelatorioTurmas(List<EnviarAoBD> minhaLista) throws SQLException  {
        String sql_1 = "insert into relatorio (aulas,coluna1) values (?,?)";
        String sql_2 = "insert into relatorio (aulas,coluna1,coluna2) values (?,?,?)";
        String sql_3 = "insert into relatorio (aulas,coluna1,coluna2,coluna3) values (?,?,?,?)";
        String sql_4 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4) values (?,?,?,?,?)";
        String sql_5 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5) values (?,?,?,?,?,?)";
        String sql_6 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6) values (?,?,?,?,?,?,?)";
        String sql_7 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7) values (?,?,?,?,?,?,?,?)";
        String sql_8 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8) values (?,?,?,?,?,?,?,?,?)";
        String sql_9 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8,coluna9) values (?,?,?,?,?,?,?,?,?,?)";
        String sql_10 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8,coluna9,coluna10) values (?,?,?,?,?,?,?,?,?,?,?)";
        String sql_11 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8,coluna9,coluna10,coluna11) values (?,?,?,?,?,?,?,?,?,?,?,?)";
        String sql_12 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8,coluna9,coluna10,coluna11,coluna12) values (?,?,?,?,?,?,?,?,?,?,?,?,?)";
        String sql_13 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8,coluna9,coluna10,coluna11,coluna12,coluna13) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        String sql_14 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8,coluna9,coluna10,coluna11,coluna12,coluna13,coluna14) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        String sql_15 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8,coluna9,coluna10,coluna11,coluna12,coluna13,coluna14,coluna15) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        String sql_16 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8,coluna9,coluna10,coluna11,coluna12,coluna13,coluna14,coluna15,coluna16) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        String sql_17 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8,coluna9,coluna10,coluna11,coluna12,coluna13,coluna14,coluna15,coluna16,coluna17) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        String sql_18 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8,coluna9,coluna10,coluna11,coluna12,coluna13,coluna14,coluna15,coluna16,coluna17,coluna18) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        String sql_19 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8,coluna9,coluna10,coluna11,coluna12,coluna13,coluna14,coluna15,coluna16,coluna17,coluna18,coluna19) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        String sql_20 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8,coluna9,coluna10,coluna11,coluna12,coluna13,coluna14,coluna15,coluna16,coluna17,coluna18,coluna19,coluna20) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        String sql_21 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8,coluna9,coluna10,coluna11,coluna12,coluna13,coluna14,coluna15,coluna16,coluna17,coluna18,coluna19,coluna20,coluna21) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        String sql_22 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8,coluna9,coluna10,coluna11,coluna12,coluna13,coluna14,coluna15,coluna16,coluna17,coluna18,coluna19,coluna20,coluna21,coluna22) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        String sql_23 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8,coluna9,coluna10,coluna11,coluna12,coluna13,coluna14,coluna15,coluna16,coluna17,coluna18,coluna19,coluna20,coluna21,coluna22,coluna23) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        String sql_24 = "insert into relatorio (aulas,coluna1,coluna2,coluna3,coluna4,coluna5,coluna6,coluna7,coluna8,coluna9,coluna10,coluna11,coluna12,coluna13,coluna14,coluna15,coluna16,coluna17,coluna18,coluna19,coluna20,coluna21,coluna22,coluna23,coluna24) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        
        
        
        int turmas=minhaLista.size()-1;
        if(turmas==1){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_1)) {
                for(int i=0,ind=1;minhaLista.size()>i;i++,ind++){
                stmt.setString(ind, minhaLista.get(i).getAnoturma());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==2){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_2)) {
                for(int i=0,ind=1;minhaLista.size()>i;i++,ind++){
                stmt.setString(ind, minhaLista.get(i).getAnoturma());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==3){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_3)) {
                for(int i=0,ind=1;minhaLista.size()>i;i++,ind++){
                stmt.setString(ind, minhaLista.get(i).getAnoturma());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==4){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_4)) {
                for(int i=0,ind=1;minhaLista.size()>i;i++,ind++){
                stmt.setString(ind, minhaLista.get(i).getAnoturma());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==5){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_5)) {
                for(int i=0,ind=1;minhaLista.size()>i;i++,ind++){
                stmt.setString(ind, minhaLista.get(i).getAnoturma());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==6){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_6)) {
                for(int i=0,ind=1;minhaLista.size()>i;i++,ind++){
                stmt.setString(ind, minhaLista.get(i).getAnoturma());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==7){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_7)) {
                for(int i=0,ind=1;minhaLista.size()>i;i++,ind++){
                stmt.setString(ind, minhaLista.get(i).getAnoturma());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==8){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_8)) {
                for(int i=0,ind=1;minhaLista.size()>i;i++,ind++){
                stmt.setString(ind, minhaLista.get(i).getAnoturma());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==9){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_9)) {
                for(int i=0,ind=1;minhaLista.size()>i;i++,ind++){
                stmt.setString(ind, minhaLista.get(i).getAnoturma());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==10){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_10)) {
                for(int i=0,ind=1;minhaLista.size()>i;i++,ind++){
                stmt.setString(ind, minhaLista.get(i).getAnoturma());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==11){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_11)) {
                for(int i=0,ind=1;minhaLista.size()>i;i++,ind++){
                stmt.setString(ind, minhaLista.get(i).getAnoturma());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==12){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_12)) {
                for(int i=0,ind=1;minhaLista.size()>i;i++,ind++){
                stmt.setString(ind, minhaLista.get(i).getAnoturma());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==13){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_13)) {
                for(int i=0,ind=1;minhaLista.size()>i;i++,ind++){
                stmt.setString(ind, minhaLista.get(i).getAnoturma());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==14){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_14)) {
                for(int i=0,ind=1;minhaLista.size()>i;i++,ind++){
                stmt.setString(ind, minhaLista.get(i).getAnoturma());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==15){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_15)) {
                for(int i=0,ind=1;minhaLista.size()>i;i++,ind++){
                stmt.setString(ind, minhaLista.get(i).getAnoturma());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==16){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_16)) {
                for(int i=0,ind=1;minhaLista.size()>i;i++,ind++){
                stmt.setString(ind, minhaLista.get(i).getAnoturma());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==17){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_17)) {
                for(int i=0,ind=1;minhaLista.size()>i;i++,ind++){
                stmt.setString(ind, minhaLista.get(i).getAnoturma());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==18){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_18)) {
                for(int i=0,ind=1;minhaLista.size()>i;i++,ind++){
                stmt.setString(ind, minhaLista.get(i).getAnoturma());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==19){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_19)) {
                for(int i=0,ind=1;minhaLista.size()>i;i++,ind++){
                stmt.setString(ind, minhaLista.get(i).getAnoturma());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==20){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_20)) {
                for(int i=0,ind=1;minhaLista.size()>i;i++,ind++){
                stmt.setString(ind, minhaLista.get(i).getAnoturma());
                                                                 }
                stmt.execute();
            }
                     }
        
        if(turmas==21){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_21)) {
                for(int i=0,ind=1;minhaLista.size()>i;i++,ind++){
                stmt.setString(ind, minhaLista.get(i).getAnoturma());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==22){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_22)) {
                for(int i=0,ind=1;minhaLista.size()>i;i++,ind++){
                stmt.setString(ind, minhaLista.get(i).getAnoturma());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==23){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_23)) {
                for(int i=0,ind=1;minhaLista.size()>i;i++,ind++){
                stmt.setString(ind, minhaLista.get(i).getAnoturma());
                                                                 }
                stmt.execute();
            }
                     }
        if(turmas==24){
            try (PreparedStatement stmt = conexao.prepareStatement(sql_24)) {
                for(int i=0,ind=1;minhaLista.size()>i;i++,ind++){
                stmt.setString(ind, minhaLista.get(i).getAnoturma());
                                                                 }
                stmt.execute();
            }
                     }
        
    }

    public int VerificaQuatdeHA() throws SQLException {
         String sql = "select SUM( horas_aula ) from hora_aula";
        int id=0;
  
        
            try (PreparedStatement stmt = (PreparedStatement) conexao.prepareStatement(sql)) {
                
                try (ResultSet rs = stmt.executeQuery()) {
                    
                    while (rs.next()){
                        
                        id=rs.getInt("SUM");
                    }
                }
            }
           
        
          return id;
    }

    public void PassapraTab2() throws SQLException {
        String sql = "select hora_aula.id_ha, hora_aula.id_serie_turma_ha, hora_aula.id_prof_ha, hora_aula.id_disc_ha, hora_aula.horas_aula from hora_aula";
        List<Objeto> minhaLista;
        try (PreparedStatement stmt = (PreparedStatement) conexao.prepareStatement(sql); ResultSet rs = (ResultSet) stmt.executeQuery()) {
            minhaLista = new ArrayList<>();
            while (rs.next()) {
                DadosStatic.setDadosinsersos(DadosStatic.getDadosinsersos()+1);
                Objeto a1 = new Objeto();
                a1.setId_HA(rs.getInt("id_ha"));
                a1.setId_serie(rs.getInt("id_serie_turma_ha"));
                a1.setId_prof(rs.getInt("id_prof_ha"));
                a1.setId_disc(rs.getInt("id_disc_ha"));
                a1.setHA(rs.getInt("horas_aula"));     
            minhaLista.add(a1);
            }
        }
        
        String sql_1 = "insert into hora_aula2 (id_ha2,id_serie_turma_ha2,id_prof_ha2,id_disc_ha2,horas_aula2) values (?,?,?,?,?)";
        
        
        for(int i=0;minhaLista.size()>i;i++){
           PreparedStatement stmt = conexao.prepareStatement(sql_1);
                
                stmt.setInt(1, minhaLista.get(i).getId_HA());
                stmt.setInt(2, minhaLista.get(i).getId_serie());
                stmt.setInt(3, minhaLista.get(i).getId_prof());
                stmt.setInt(4, minhaLista.get(i).getId_disc());
                stmt.setInt(5, minhaLista.get(i).getHA());
                                                                 
                stmt.execute();
            }
                     
      
             
    }

    public void RepassapraTab1() throws SQLException {
        String sql = "select hora_aula2.id_ha2, hora_aula2.id_serie_turma_ha2, hora_aula2.id_prof_ha2, hora_aula2.id_disc_ha2, hora_aula2.horas_aula2 from hora_aula2";
        List<Objeto> minhaLista;
        try (PreparedStatement stmt = (PreparedStatement) conexao.prepareStatement(sql); ResultSet rs = (ResultSet) stmt.executeQuery()) {
            minhaLista = new ArrayList<>();
            while (rs.next()) {
                Objeto a1 = new Objeto();
                a1.setId_HA(rs.getInt("id_ha2"));
                a1.setId_serie(rs.getInt("id_serie_turma_ha2"));
                a1.setId_prof(rs.getInt("id_prof_ha2"));
                a1.setId_disc(rs.getInt("id_disc_ha2"));
                a1.setHA(rs.getInt("horas_aula2"));     
            minhaLista.add(a1);
            }
        }
        
        String sql_1 = "insert into hora_aula (id_ha,id_serie_turma_ha,id_prof_ha,id_disc_ha,horas_aula) values (?,?,?,?,?)";
        
        
        for(int i=0;minhaLista.size()>i;i++){
           DadosStatic.setDadosinsersos(DadosStatic.getDadosinsersos()+1);
           
           PreparedStatement stmt = conexao.prepareStatement(sql_1);
                
                stmt.setInt(1, minhaLista.get(i).getId_HA());
                stmt.setInt(2, minhaLista.get(i).getId_serie());
                stmt.setInt(3, minhaLista.get(i).getId_prof());
                stmt.setInt(4, minhaLista.get(i).getId_disc());
                stmt.setInt(5, minhaLista.get(i).getHA());
                                                                 
                stmt.execute();
            }
          String sql_2 = "delete from hora_aula2";
            try (PreparedStatement consulta_2 = (PreparedStatement) conexao.prepareStatement(sql_2)) {
                
                consulta_2.execute();
            } 
            
            
    
    }

    public void Passapratab2DiasAulas() throws SQLException {
        String sql3 = "select prof_dia_aula.id_prof_pda, prof_dia_aula.id_dia_pda, prof_dia_aula.id_aula_pda from prof_dia_aula";
        List<Objeto> minhaLista3;
        try (PreparedStatement stmt3 = (PreparedStatement) conexao.prepareStatement(sql3); ResultSet rs3 = (ResultSet) stmt3.executeQuery()) {
            minhaLista3 = new ArrayList<>();
            while (rs3.next()) {
                DadosStatic.setDadosinsersos(DadosStatic.getDadosinsersos()+1);
                Objeto a1 = new Objeto();
                a1.setId_prof(rs3.getInt("id_prof_pda"));
                a1.setDia(rs3.getInt("id_dia_pda"));
                a1.setAula(rs3.getInt("id_aula_pda"));
                    
            minhaLista3.add(a1);
            }
        }
        
        String sql_4 = "insert into prof_dia_aula2 (id_prof_pda2,id_dia_pda2,id_aula_pda2) values (?,?,?)";
        
        
        for(int i=0;minhaLista3.size()>i;i++){
           PreparedStatement stmt = conexao.prepareStatement(sql_4);
                
                stmt.setInt(1, minhaLista3.get(i).getId_prof());
                stmt.setInt(2, minhaLista3.get(i).getDia());
                stmt.setInt(3, minhaLista3.get(i).getAula());
                
                                                                 
                stmt.execute();
            }
    }

    public void RepassapraTab1DiasAulas() throws SQLException {
        String sql = "delete from prof_dia_aula";
            try (PreparedStatement consulta_2 = (PreparedStatement) conexao.prepareStatement(sql)) {
                
                consulta_2.execute();
            } 
        
        
         String sql3 = "select prof_dia_aula2.id_prof_pda2, prof_dia_aula2.id_dia_pda2, prof_dia_aula2.id_aula_pda2 from prof_dia_aula2";
        List<Objeto> minhaLista3;
        try (PreparedStatement stmt3 = (PreparedStatement) conexao.prepareStatement(sql3); ResultSet rs3 = (ResultSet) stmt3.executeQuery()) {
            minhaLista3 = new ArrayList<>();
            while (rs3.next()) {
                Objeto a1 = new Objeto();
                a1.setId_prof(rs3.getInt("id_prof_pda2"));
                a1.setDia(rs3.getInt("id_dia_pda2"));
                a1.setAula(rs3.getInt("id_aula_pda2"));
                 
            minhaLista3.add(a1);
            }
        }
        
        String sql_4 = "insert into prof_dia_aula (id_prof_pda,id_dia_pda,id_aula_pda) values (?,?,?)";
        
        
        for(int i=0;minhaLista3.size()>i;i++){
           PreparedStatement stmt = conexao.prepareStatement(sql_4);
                DadosStatic.setDadosinsersos(DadosStatic.getDadosinsersos()+1);
                stmt.setInt(1, minhaLista3.get(i).getId_prof());
                stmt.setInt(2, minhaLista3.get(i).getDia());
                stmt.setInt(3, minhaLista3.get(i).getAula());
                
                                                                 
                stmt.execute();
            }
          String sql_5 = "delete from prof_dia_aula2";
            try (PreparedStatement consulta_2 = (PreparedStatement) conexao.prepareStatement(sql_5)) {
                
                consulta_2.execute();
            } 
            String sql2 = "delete from prof_dia_aula where prof_dia_aula.id_aula_pda=10";
            try (PreparedStatement consulta_6 = (PreparedStatement) conexao.prepareStatement(sql2)) {
                
                consulta_6.execute();
            }
    }
    
    public void RepassapraTab1DiasAulas2() throws SQLException {
        
        
        
         String sql3 = "select prof_dia_aula3.id_prof_pda3, prof_dia_aula3.id_dia_pda3, prof_dia_aula3.id_aula_pda3 from prof_dia_aula3";
        List<Objeto> minhaLista3;
        try (PreparedStatement stmt3 = (PreparedStatement) conexao.prepareStatement(sql3); ResultSet rs3 = (ResultSet) stmt3.executeQuery()) {
            minhaLista3 = new ArrayList<>();
            while (rs3.next()) {
                Objeto a1 = new Objeto();
                a1.setId_prof(rs3.getInt("id_prof_pda3"));
                a1.setDia(rs3.getInt("id_dia_pda3"));
                a1.setAula(rs3.getInt("id_aula_pda3"));
                 
            minhaLista3.add(a1);
            }
        }
        
        String sql_4 = "insert into prof_dia_aula (id_prof_pda,id_dia_pda,id_aula_pda) values (?,?,?)";
        
        
        for(int i=0;minhaLista3.size()>i;i++){
           PreparedStatement stmt = conexao.prepareStatement(sql_4);
                
                stmt.setInt(1, minhaLista3.get(i).getId_prof());
                stmt.setInt(2, minhaLista3.get(i).getDia());
                stmt.setInt(3, minhaLista3.get(i).getAula());
                
                                                                 
                stmt.execute();
            }
          String sql_5 = "delete from prof_dia_aula3";
            try (PreparedStatement consulta_2 = (PreparedStatement) conexao.prepareStatement(sql_5)) {
                
                consulta_2.execute();
            } 
    }

    public void PassapraTab2prof() throws SQLException {
        String sql3 = "select professor.id_prof, professor.nome_prof, professor.carga_horaria from professor";
        List<Objeto> minhaLista3;
        try (PreparedStatement stmt3 = (PreparedStatement) conexao.prepareStatement(sql3); ResultSet rs3 = (ResultSet) stmt3.executeQuery()) {
            minhaLista3 = new ArrayList<>();
            while (rs3.next()) {
                DadosStatic.setDadosinsersos(DadosStatic.getDadosinsersos()+1);
                Objeto a1 = new Objeto();
                a1.setId_prof(rs3.getInt("id_prof"));
                a1.setNomeprof(rs3.getString("nome_prof"));
                a1.setCH(rs3.getInt("carga_horaria"));
                    
            minhaLista3.add(a1);
            }
        }
        
        String sql_4 = "insert into professor2 (id_prof2,nome_prof2,carga_horaria2) values (?,?,?)";
        
        
        for(int i=0;minhaLista3.size()>i;i++){
           PreparedStatement stmt = conexao.prepareStatement(sql_4);
                
                stmt.setInt(1, minhaLista3.get(i).getId_prof());
                stmt.setString(2, minhaLista3.get(i).getNomeprof());
                stmt.setInt(3, minhaLista3.get(i).getCH());
                
                                                                 
                stmt.execute();
            }
    }

    public void RepassapraTab1prof() throws SQLException {
        
        
        
         String sql3 = "select professor2.id_prof2, professor2.nome_prof2, professor2.carga_horaria2 from professor2";
        List<Objeto> minhaLista3;
        try (PreparedStatement stmt3 = (PreparedStatement) conexao.prepareStatement(sql3); ResultSet rs3 = (ResultSet) stmt3.executeQuery()) {
            minhaLista3 = new ArrayList<>();
            while (rs3.next()) {
                Objeto a1 = new Objeto();
                a1.setId_prof(rs3.getInt("id_prof2"));
                a1.setNomeprof(rs3.getString("nome_prof2"));
                a1.setCH(rs3.getInt("carga_horaria2"));
                 
            minhaLista3.add(a1);
            }
        }
        
        String sql_4 = "UPDATE professor SET carga_horaria=? WHERE id_prof=?";
        
        
        for(int i=0;minhaLista3.size()>i;i++){
           PreparedStatement stmt = conexao.prepareStatement(sql_4);
                DadosStatic.setDadosinsersos(DadosStatic.getDadosinsersos()+1);
                
                stmt.setInt(2, minhaLista3.get(i).getId_prof());
                
                stmt.setInt(1, minhaLista3.get(i).getCH());
                
                                                                 
                stmt.execute();
            }
          String sql_5 = "delete from professor2";
            try (PreparedStatement consulta_2 = (PreparedStatement) conexao.prepareStatement(sql_5)) {
                
                consulta_2.execute();
            } 
    }

    public boolean HouverDados() {
        String sql3 = "select professor2.id_prof2, professor2.nome_prof2, professor2.carga_horaria2 from professor2";
        int i=0;
        try {
       PreparedStatement stmt3 = (PreparedStatement) conexao.prepareStatement(sql3); 
       ResultSet rs3 = (ResultSet) stmt3.executeQuery();
        
            while (rs3.next()) {
                i=1;
            
            }
        } catch (SQLException ex) {
            Logger.getLogger(ObjetoMet.class.getName()).log(Level.SEVERE, null, ex);
        }
            
         String sql1 = "select *  from hora_aula2 ";
        int j=0;
        try {
       PreparedStatement stmt3 = (PreparedStatement) conexao.prepareStatement(sql1); 
       ResultSet rs3 = (ResultSet) stmt3.executeQuery();
        
            while (rs3.next()) {
                j=1;
            
            }
        } catch (SQLException ex) {
            Logger.getLogger(ObjetoMet.class.getName()).log(Level.SEVERE, null, ex);
        }   
            String sql2 = "select *  from prof_dia_aula2";
        int y=0;
        try {
       PreparedStatement stmt3 = (PreparedStatement) conexao.prepareStatement(sql2); 
       ResultSet rs3 = (ResultSet) stmt3.executeQuery();
        
            while (rs3.next()) {
                j=1;
            
            }
        } catch (SQLException ex) {
            Logger.getLogger(ObjetoMet.class.getName()).log(Level.SEVERE, null, ex);
        }    
            
            if(i==0 && j==0 && y==0){
                return false;
            }else{
                return true;
            }
        }

    public void DeletaTabHA() throws SQLException {
         String sql_5 = "delete from hora_aula";
            PreparedStatement consulta_2 = (PreparedStatement) conexao.prepareStatement(sql_5);
                
                consulta_2.execute();
           
    }
    
    public void DeletarTabHorarioTabRelProf() throws SQLException {
         String sql_5 = "delete from rel_prof";
            PreparedStatement consulta_2 = (PreparedStatement) conexao.prepareStatement(sql_5);
                
                consulta_2.execute();
           
         String sql = "delete from relatorio";
            PreparedStatement consulta = (PreparedStatement) conexao.prepareStatement(sql);
                
                consulta.execute();
                
         String sql2 = "delete from rel_turma";
            PreparedStatement consulta2 = (PreparedStatement) conexao.prepareStatement(sql2);
                
                consulta2.execute();
           
    }

    public int QuatRegistro() throws SQLException {
        int ha=0,pda=0,prof=0;
        String sql1="select COUNT(hora_aula2.id_ha2) from  hora_aula2";
        String sql2="select COUNT(prof_dia_aula2.id_prof_pda2) from  prof_dia_aula2";
        String sql3="select COUNT(professor2.id_prof2) from  professor2";
        PreparedStatement stmt = (PreparedStatement) conexao.prepareStatement(sql1); 
        ResultSet rs = (ResultSet) stmt.executeQuery();
        
            while (rs.next()) {
                ha=rs.getInt("COUNT");
            
            }
        PreparedStatement stmt2 = (PreparedStatement) conexao.prepareStatement(sql2); 
        ResultSet rs2 = (ResultSet) stmt2.executeQuery();
        
            while (rs2.next()) {
                pda=rs2.getInt("COUNT");
            
            }
        PreparedStatement stmt3 = (PreparedStatement) conexao.prepareStatement(sql3); 
        ResultSet rs3 = (ResultSet) stmt3.executeQuery();
        
            while (rs3.next()) {
                prof=rs3.getInt("COUNT");
            
            }    
            return ha+pda+prof;
    }

    public int BuscaIdSerie(String columnName) {
        int id=-1;
        String serieturma;
        String sql="select serie.id_serie, serie.nome_serie, descricao.descricao_desc from descricao, serie where serie.id_turma_s=descricao.id_desc";
        try {
        PreparedStatement stmt = (PreparedStatement) conexao.prepareStatement(sql); 
        ResultSet rs = (ResultSet) stmt.executeQuery();
        
            while (rs.next()) {
                serieturma=rs.getString("nome_serie")+rs.getString("descricao_desc");
                if(serieturma.equals(columnName)){
                    id=rs.getInt("id_serie");
                }
               
            
            }
        } catch (SQLException ex) {
            Logger.getLogger(ObjetoMet.class.getName()).log(Level.SEVERE, null, ex);
        }
            return id;
    }

    public void AdicionaRelatorioProf(Relatorio_Prof rp) {
        String sql = "insert into rel_prof (id_prof_rp,id_disc_rp,id_serie_rp,ch_depois,id_dia_rp,id_aula_rp) values (?,?,?,?,?,?)";
        try {
           PreparedStatement stmt = conexao.prepareStatement(sql);
                
                stmt.setInt(1, rp.getId_prof());
                stmt.setInt(2,rp.getId_disc());
                stmt.setInt(3, rp.getId_serie());
                stmt.setInt(4, rp.getCh_depois());
                stmt.setInt(5,rp.getDias());
                stmt.setInt(6, rp.getAula());
       
            stmt.execute();
        } catch (SQLException ex) {
            Logger.getLogger(ObjetoMet.class.getName()).log(Level.SEVERE, null, ex);
        }
            }

    public int QuatRegistro2() throws SQLException {
         int ha=0,pda=0,prof=0;
        String sql1="select COUNT(hora_aula.id_ha) from  hora_aula";
        String sql2="select COUNT(prof_dia_aula.id_prof_pda) from  prof_dia_aula";
        String sql3="select COUNT(professor.id_prof) from  professor";
        PreparedStatement stmt = (PreparedStatement) conexao.prepareStatement(sql1); 
        ResultSet rs = (ResultSet) stmt.executeQuery();
        
            while (rs.next()) {
                ha=rs.getInt("COUNT");
            
            }
        PreparedStatement stmt2 = (PreparedStatement) conexao.prepareStatement(sql2); 
        ResultSet rs2 = (ResultSet) stmt2.executeQuery();
        
            while (rs2.next()) {
                pda=rs2.getInt("COUNT");
            
            }
        PreparedStatement stmt3 = (PreparedStatement) conexao.prepareStatement(sql3); 
        ResultSet rs3 = (ResultSet) stmt3.executeQuery();
        
            while (rs3.next()) {
                prof=rs3.getInt("COUNT");
            
            }    
            return (ha*3)+(pda*3)+(prof*3);
    }

    public int buscaid_gerar() throws SQLException {
        int id=0;
        String sql1="select tela.id_gerar from tela";
        
        PreparedStatement stmt = (PreparedStatement) conexao.prepareStatement(sql1); 
        ResultSet rs = (ResultSet) stmt.executeQuery();
        
            while (rs.next()) {
               id=rs.getInt("id_gerar");
            
            }
       
            return id;
    }
   
    public void atualiza_id_gerar(int i) throws SQLException {
    
     String sql_4 = "UPDATE tela set id_gerar=?";
        
        
     
           PreparedStatement stmt = conexao.prepareStatement(sql_4);
             
                
                
                
                stmt.setInt(1, i);
                
                                                                 
                stmt.execute();
            
    }

    public void AdicionaRelatorioTurmas(Relatorio_Prof rp) {
        String sql = "insert into rel_turma (id_serie_rt,id_aula_rt,id_dia_rt,dados_rt) values (?,?,?,?)";
        try {
           PreparedStatement stmt = conexao.prepareStatement(sql);
                
                stmt.setInt(1, rp.getId_serie());
                stmt.setInt(2, rp.getAula());
                stmt.setInt(3, rp.getDias());
                stmt.setString(4,rp.getNome_disc());
       
            stmt.execute();
        } catch (SQLException ex) {
            Logger.getLogger(ObjetoMet.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void Deleta10Haulas() {
        String sql2 = "delete from prof_dia_aula where prof_dia_aula.id_aula_pda=10";
            PreparedStatement consulta_6;
        try {
            consulta_6 = (PreparedStatement) conexao.prepareStatement(sql2);
        
                
                consulta_6.execute();
            } catch (SQLException ex) {
            Logger.getLogger(ObjetoMet.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void Remove3diasaulasdisponivel(Objeto obj, Objeto obj2, Objeto obj3) {
        DadosStatic.setDadosinsersos(DadosStatic.getDadosinsersos()+2);
        String sql_e = "delete from prof_dia_aula where id_prof_pda= ? and id_dia_pda=? and id_aula_pda=? ";
        PreparedStatement consulta_e;
        try {
            consulta_e = (PreparedStatement) conexao.prepareStatement(sql_e);
             consulta_e.setInt(1, obj.getId_prof());
             consulta_e.setInt(2, obj.getDia());
              consulta_e.setInt(3, obj.getAula());
             
        consulta_e.execute();
        consulta_e.close();
        } catch (SQLException ex) {
            Logger.getLogger(ObjetoMet.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        
        String sql_1 = "delete from prof_dia_aula where id_prof_pda= ? and id_dia_pda=? and id_aula_pda=? ";
        PreparedStatement consulta_1;
        try {
            consulta_1 = (PreparedStatement) conexao.prepareStatement(sql_1);
             consulta_1.setInt(1, obj2.getId_prof());
             consulta_1.setInt(2, obj2.getDia());
             consulta_1.setInt(3, obj2.getAula());
             
        consulta_1.execute();
        consulta_1.close();
        } catch (SQLException ex) {
            Logger.getLogger(ObjetoMet.class.getName()).log(Level.SEVERE, null, ex);
        }
        DadosStatic.setDadosinsersos(DadosStatic.getDadosinsersos()+1);
       String sql = "delete from prof_dia_aula where id_prof_pda= ? and id_dia_pda=? and id_aula_pda=?";
        PreparedStatement consulta;
        try {
            consulta = (PreparedStatement) conexao.prepareStatement(sql);
             consulta.setInt(1, obj3.getId_prof());
             consulta.setInt(2, obj3.getDia());
              consulta.setInt(3, obj3.getAula());
        consulta.execute();
        consulta.close();
        } catch (SQLException ex) {
            Logger.getLogger(ObjetoMet.class.getName()).log(Level.SEVERE, null, ex);
        }
        System.out.println("DELETOU A: "+obj3.getAula()+"  DIA: "+obj3.getDia()+" DO PROF: "+obj3.getNomeprof()+" Remove 3 aula Dias Disponiveis"+" NA TURMA:"+obj3.getAnoturma());
        System.out.println("DELETOU A: "+obj.getAula()+" DO PROF: "+obj.getNomeprof()+" Remove 3 aulas");
        System.out.println("DELETOU A: "+obj2.getAula()+" DO PROF: "+obj2.getNomeprof()+" Remove 3 aulas");
        
    }

    
    }


//  String sql2="select professor.id from serie,descricao,professor,disciplina,hora_aula,aulas,dias,prof_dia_aula where prof_dia_aula.id_prof=professor.id and prof_dia_aula.id_dia=dias.id and prof_dia_aula.id_aula=aulas.id and hora_aula.id_serie_turma=serie.id and serie.id_turma=descricao.id and hora_aula.id_prof=professor.id and hora_aula.id_disc=disciplina.id ";
//        PreparedStatement stmt2 = (PreparedStatement) conexao.prepareStatement(sql2);
//        ResultSet rs2 = (ResultSet) stmt2.executeQuery();
//        int i=0;
//        while(rs2.next()){
//           i++;
//        }
//        int[] prof=new int[i];
//        int y=i;
//        int z = 0;
//        String sql3="select COUNT(prof_dia_aula.id_aula) from professor,prof_dia_aula where prof_dia_aula.id_prof=professor.id and professor.id=? ";
//        PreparedStatement stmt3 = (PreparedStatement) conexao.prepareStatement(sql3);
//        while(i<0){ 
//        stmt3.setInt(1, prof[i]);
//        ResultSet rs3 = (ResultSet) stmt3.executeQuery();
//         z=0;
//        while(rs3.next()){
//           z++;
//        }
//        i--;
//        }
//        System.out.println("z="+z);
//        int[] horas_aula=new int[z];
//        int[] horas_aula2=new int[z];
//        i=0;
//        while(i>y){ 
//        stmt3.setInt(1, prof[i]);
//        ResultSet rs3 = (ResultSet) stmt3.executeQuery();
//        while(rs3.next()){
//        horas_aula[i]=rs.getInt("COUNT(prof_dia_aula.id_aula)");
//        horas_aula2[i]=horas_aula[i];
//        if(){
//            
//        }
//        }
//        i++;
//        }